<template>
  <div class="controll-container">
    <div class="breadClum">
      <span>
        <router-link :to="{path:'/pageIndex'}"><a class="bread1">当前位置：首页  >  </a></router-link>
        <router-link :to="{path:'/controlBuild/'}"> <a class="bread2">内控建设  ></a></router-link>
        <a class="bread2">资料列表</a>
      </span>
    </div>
    <div class="navList">
      <!--公司列表-->
      <el-dropdown trigger="click"
                   style="cursor:pointer;background: #8cc34b;padding:10px 24px;color:#fff;border-radius:4px;text-align: center;"
                   @command="handleCompanyList">
          <span class="el-dropdown-link">
            {{companyType}}<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
        <el-dropdown-menu    slot="dropdown" style="padding: 0 10px;height: 300px;overflow-y: scroll">
          <el-dropdown-item :command="item" v-for="item in companyTableList" :key="item.company_id">{{item.company_name}}</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>

      <!--资料分类-->
      <el-dropdown trigger="click"
                   style="cursor:pointer;background: #8cc34b;padding:10px 24px;color:#fff;border-radius:4px;text-align: center;"
                   @command="handleClassificationList">
          <span class="el-dropdown-link">
            {{classification}}<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
        <el-dropdown-menu slot="dropdown" style="padding: 0 10px;;height: 300px;overflow-y: scroll">
          <el-dropdown-item v-for="item in classificationTableList" :command="item" :key="item.dacate_id">{{item.dacate_name}}</el-dropdown-item>
          <el-dropdown-item command="none" v-if="classificationTableList.length==0">暂无数据</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>

      <!--二级分类-->
      <el-dropdown trigger="click"
                   style="cursor:pointer;background: #8cc34b;padding:10px 24px;color:#fff;border-radius:4px;width: 80px;text-align: center;"
                   @command="handleClassificationByCon2">
          <span class="el-dropdown-link">
            {{classificationByCon2}}<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
        <el-dropdown-menu slot="dropdown" style="padding: 0 10px;;height: 300px;overflow-y: scroll">
          <el-dropdown-item :command="item.dacate_id" v-for="(item,index) in classificationByCon2List" :key="item.index">{{item.dacate_name}}</el-dropdown-item>
          <el-dropdown-item command="none" v-if="classificationByCon2List.length==0">暂无数据</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>

      <!--三级分类-->
      <el-dropdown trigger="click"
                   style="cursor:pointer;background: #8cc34b;padding:10px 24px;color:#fff;border-radius:4px;width: 80px;text-align: center;"
                   @command="handleClassificationByCon3">
          <span class="el-dropdown-link">
            {{classificationByCon3}}<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
        <el-dropdown-menu slot="dropdown" style="padding: 0 10px;;height: 300px;overflow-y: scroll">
          <!--classificationByCon3List-->
          <el-dropdown-item :command="item.dacate_id" v-for="(item,index) in classificationByCon3List" :key="item.index">{{item.dacate_name}}</el-dropdown-item>
          <el-dropdown-item command="none" v-if="classificationByCon3List.length==0">暂无数据</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>

      <el-button type="primary" @click="addData">添加资料</el-button>
      <el-button style="background:#769dd6;color:#fff;border-color:#769dd6;" @click="editData">编辑分类</el-button>
      <!--<a href="https://view.officeapps.live.com/op/view.aspx?src=http://www.jwgf.com/test.xlsx" target="_blank" rel="nofollow">打开</a>-->
      <!--<a href="http://www.jwgf.com/test.pdf" target="_blank" rel="nofollow">打开</a>-->
      <!--<embed  src="http://www.jwgf.com/test.xlsx" type="application/xlsx" width="100%" height="500">-->
    </div>

    <el-table
      ref="dataListTable"
      :data="dataList"
      stripe
      @selection-change="handleSelectionChange"
      style="width: 100%">
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
      <el-table-column
        label="资料编号"
        prop="datum_num">
      </el-table-column>
      <el-table-column
        width="308px;"
        label="资料名称">
        <template slot-scope="scope">
          <a style="color:#3b6fc3;" v-if="scope.row.datum_type==1" :href="'https://view.officeapps.live.com/op/view.aspx?src=' + scope.row.datum_link" target="_blank">{{scope.row.datum_name}}</a>
          <a style="color:#3b6fc3;" v-else :href="scope.row.datum_link" target="_blank">{{scope.row.datum_name}}</a>
        </template>
      </el-table-column>
      <el-table-column
        width="246">
        <template slot="header" slot-scope="scope">
          <el-dropdown style="color:#5d9120;font-size:16px;margin-bottom:-8px;" trigger="click" @command="handleElementList">
                <span class="el-dropdown-link">
                  内控因素<em class="arrow"></em>
                </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item v-for="item in elementList" :command="item.element_id" :key="item.element_id">{{item.element_name}}</el-dropdown-item>
              <el-dropdown-item command="none" v-if="elementList.length==0">暂无数据</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
        <template slot-scope="scope">

        </template>
      </el-table-column>
      <el-table-column
        width="185">
        <template slot="header" slot-scope="scope">
          <el-dropdown style="color:#5d9120;font-size:16px;margin-bottom:-8px;" trigger="click"  @command="handleProgressList">
                <span class="el-dropdown-link">
                  评价流程<em class="arrow"></em>
                </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item v-for="item in currentElementProgress" :command="item.process_id" :key="item.process_id">{{item.process_name}}</el-dropdown-item>
              <el-dropdown-item command="none" v-if="currentElementProgress.length==0">暂无数据</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
        <template slot-scope="scope">

        </template>
      </el-table-column>
      <el-table-column
        prop="add_time"
        label="上传时间"
        width="168px">
      </el-table-column>
      <el-table-column
        prop="update_time"
        label="修改时间"
        width="168px">
      </el-table-column>
      <el-table-column
        label="是否显示"
        width="124px;">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.datum_state"
            @change="switchRow(scope.$index)"
            active-value="1"
            inactive-value="0"
            active-color="#efba12"
            inactive-color="#dddddd">
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column
        prop="leader_identify"
        label="操作"
        width="170px;">
        <template slot-scope="scope">
          <span style="color:#3b6fc3;cursor: pointer" @click="editRow(scope.$index)">编辑</span>
          <span style="color:#3b6fc3;cursor: pointer" @click="deleteRow(scope.$index)">删除</span>
        </template>
      </el-table-column>

      <el-table-column></el-table-column>
    </el-table>
    <div class="e-table-footer">
      <div class="e-selectAll">
        <el-checkbox @change = "selectAll"></el-checkbox>
      </div>
      <div class="e-selectText">
        <span>全选</span>
        <span class="e-del" @click.stop="deleteBtn">删除</span>
      </div>
    </div>

    <!--添加资料-->
    <el-dialog
      :title="title"
      :visible.sync="addDataIng"
      @close="closeAddData"
      width="580px">
      <el-form
        :model="addDataForm"
        ref="addDataForm"
        label-width="20%"
        style="min-width: 510px;">
        <el-form-item label="资料分类" :rules="[ { required: true, message:'请输入活动名称', trigger: 'blur' }]">
          <el-tree
            ref="classificationListTree"
            :data="classificationListDialog"
            show-checkbox
            @check="nodeClick"
            @check-change="handleClick"
            :check-strictly=true
            default-expand-all
            node-key="dacate_id"
            :props="defaultProps">
          </el-tree>
        </el-form-item>
        <el-form-item label="内控要素" :rules="[ { required: true, message:'请选择内控要素', trigger: 'blur' }]">
          <el-select v-model="addDataForm.element_id" @change="modifyElement">
            <el-option v-for="item in elementListDialog" :label="item.element_name" :value="item.element_id" :key="item.element_id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="评价流程" :rules="[ { required: true, message:'请选择评价流程', trigger: 'blur' }]">
          <el-select v-model="addDataForm.process_id" multiple>
            <el-option v-for="item in currentElementProgressDialog" :label="item.process_name" :value="item.process_id" :key="item.process_id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="上传文件" :rules="[{ required: true, message:'请上传文件', trigger: 'blur' }]">
          <el-upload
            ref="fileloader"
            class='file-uploader'
            :multiple=false
            list-type='text'
            :file-list="fileList"
            :limit="1"
            name="datum_file"
            :on-remove="removeData"
            :before-remove="beforeRemove"
            action="/api/v1/build/datumupload"
            :headers="headers"
            accept=".gif,.jpg,.jpeg,.bmp,.png,.xls,.xlsx,.txt,.docx,.doc,.pdf,.GIF,.JPG,.JPEG,.BMP,.PNG,.XLS,.XLSX,.TXT,.DOCX,.DOC,.PDF"
            :beforeUpload = "beforeUploadExamine"
            :on-success="uploadSuccess">
            <span class="upload-button"><i class="el-icon-upload el-icon--right" style="margin-right: 4px;"></i>选择文件</span>
          </el-upload>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addDataIng = false">取 消</el-button>
        <el-button type="primary" @click="submitData('addDataForm')">提 交</el-button>
      </span>
    </el-dialog>

    <!--分页器-->
    <div class="pagination">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="page"
        :page-size="limit"
        background
        layout="prev, pager, next, jumper"
        :page-count="pages">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  import {mapState} from 'vuex'
  import {
    strToHexCharCode,
    toFixedBit,
    dec2hex,
    formatTime,
    getNewDate
  } from "@/utils/index.js";
  import {treeToArraysDacate , treeToArraysCompany} from '@/page/test/catalog.js'
  var mdSecret = "fangyou968123456";

  export default ({
    components: {
    },
    data() {
      return {
        title:"添加资料",
        companyType:'公司列表',
        companyList:[],
        company_id:'',
        classification:'资料分类',
        first_cate:'',
        classificationList:[], //资料分类列表
        classificationListDialog:[],//用于在弹窗中使用的
        classificationByCon2:'二级分类',
        second_cate:"",
        classificationByCon2List:[],//二级分类列表
        classificationByCon3:'三级分类',
        classificationByCon3List:[],
        third_cate:"",
        element_id:"",
        process_id:"",
        page:1,
        limit:10,
        pages:1,
        dataList:null,
        fileList:[],
        addDataIng:false,
        multipleSelection:[],
        addDataForm:{
          dacate_id:'',
          element_id:'',
          process_id:[],
          datum_name:'',
          file_path:''
        },
        headers: {},//上传文件请求头
        elementList:[],//内控要素列表
        currentElementProgress:[],//当前元素下的一级流程列表
        elementListDialog:[],//添加资料 内控元素
        currentElementProgressDialog:[], //添加资料 评价流程
        isEditOrModify:0, //0 表示添加   1 表示编辑
        currentDatumId:'',
        defaultProps:{
          children: 'son_dacate',
          label: 'dacate_name'
        }
      }
    },
    // company_id,first_cate,second_cate,third_cate,element_id,process_id,
    created() {
      var currentTime = parseInt(
        getNewDate(formatTime(new Date())).getTime() / 1000
      );
      this.headers = {
        token: toFixedBit(
          strToHexCharCode(`${mdSecret}${currentTime}`),
          52,
          true,
          0,
          true
        ),
        timeStamp: currentTime,
        sign: this.MD5(
          `${sessionStorage.getItem("user_name")}${sessionStorage.getItem(
            "token"
          )}${currentTime}`
        )
      };

      // console.log(treeToArraysDacate)
      this.getCompanyList();
      this.getClassificationList();

      this.getElementList().then(res=>{
        if (res.data.code == 0 && res.data.data.length>0) {
          this.elementList = [...res.data.data,{
            element_id: "all",
            element_name: "所有",
            element_number: "",
            numrow: ""
          }];
          this.elementListDialog = res.data.data;
          this.addDataForm.element_id = res.data.data[0].element_id;
        }
        console.log(this.elementList)
      }).then(()=>{
        this.getCurrentElementProgress(this.addDataForm.element_id).then(res=>{
          console.log(res.data.data)
          if(res.data.code==0){
            this.currentElementProgressDialog = res.data.data;
            console.log(res.data.data);
            if(res.data.data[0]){
              this.addDataForm.process_id.push(res.data.data[0].process_id);
            }
          }
        })
      })
      console.log(this.addDataForm)
      console.log(this.company_ids)
      this.getTableDataByCondition(this.company_ids,this.first_cate,this.second_cate,this.third_cate,this.element_id,this.process_id,this.limit,this.page);
    },
    computed: {
      ...mapState({
        company_names: state => state.app.loginState.company_name || sessionStorage.getItem('company_name'),
        company_ids: state => state.app.loginState.company_id || sessionStorage.getItem('company_id')
      }),
      classificationTableList: function () {
        let tmp;
        console.log('XXXXXXXXXXXXXXXXXXXXXXXX')
        if (!Array.isArray(this.classificationList)) {
          tmp = [this.classificationList]
        } else {
          tmp = this.classificationList
        }
        const func = this.evalFunc || treeToArraysDacate
        // 'son_dacate'
        const args = this.evalArgs ? Array.concat([tmp, this.expandAll], this.evalArgs) : [tmp, this.expandAll]
        console.log(args)
        console.log(func.apply(null, args))
        return func.apply(null, args)
      },

      // classificationDialogTableList: function () {
      //   let tmp;
      //   console.log('XXXXXXXXXXXXXXXXXXXXXXXX')
      //   if (!Array.isArray(this.classificationListDialog)) {
      //     tmp = [this.classificationListDialog]
      //   } else {
      //     tmp = this.classificationListDialog
      //   }
      //   const func = this.evalFunc || treeToArraysDacate
      //   // 'son_dacate'
      //   const args = this.evalArgs ? Array.concat([tmp, this.expandAll], this.evalArgs) : [tmp, this.expandAll]
      //   console.log(args)
      //   console.log(func.apply(null, args))
      //   return func.apply(null, args)
      // },
      companyTableList: function () {
        let tmp;
        console.log('XXXXXXXXXXXXXXXXXXXXXXXX')
        if (!Array.isArray(this.companyList)) {
          tmp = [this.companyList]
        } else {
          tmp = this.companyList
        }
        const func = this.evalFunc || treeToArraysCompany
        const args = this.evalArgs ? Array.concat([tmp, this.expandAll], this.evalArgs) : [tmp, this.expandAll]
        console.log(args)
        console.log(func.apply(null, args))
        return func.apply(null, args)
      }

    },
    methods: {
      handleTabList(command){
        console.log(command)
      },
      removeData(file, fileList) {
        console.log(file, fileList);
        console.log('移出文件');
        this.addDataForm.datum_name = '';
        this.addDataForm.file_path = '';
      },
      beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${ file.name }？`);
      },
      editRow(index){
        var that = this;
        this.isEditOrModify = 1;
        this.title = "编辑资料";
        console.log(this.dataList[index])
        var temp = this.dataList[index]

        this.currentDatumId = temp.datum_id;
        this.getAllClassificationList();
        this.getDetails(temp.datum_id).then(res=>{
          res = res.data.data;
          console.log(res)
          var addDataForm_temp = {
            dacate_id:res.dacate_id,
            element_id:res.element_id,
            process_id:[],
            datum_name:res.datum_name,
            file_path:res.datum_link
          };

          res.process_list.forEach(el=>{
            addDataForm_temp.process_id.push(el.process_id)
          })

          this.fileList =[
            {
              name:res.datum_name,
              url:res.datum_link
            }
          ];
          this.addDataForm = addDataForm_temp;

          // this.$refs.classificationListTree.setCheckedKeys([res.dacate_id]);

          console.log(this.addDataForm)

          this.getCurrentElementProgress(res.element_id).then(resp=>{
            console.log(resp.data.data)
            if(resp.data.code==0){
              this.currentElementProgressDialog = resp.data.data;
            }
          }).then(()=>{
            this.addDataIng = true;
          }).then(()=>{
            console.log(this.$refs.classificationListTree)
            this.$refs.classificationListTree.setCheckedKeys([res.dacate_id]);
          })

        })
        console.log(this.addDataForm)
      },
      deleteRow(index){
        console.log(index)
        console.log(this.dataList[index])

        this.deleteItem(this.dataList[index].datum_id).then(res=>{
          this.$alert(res.data.message,"提示")
          if(res.data.code==0){
            this.dataList.splice(index,1);
          }
        })
      },
      switchRow(index){
        console.log(this.dataList[index])
        this.upDateUploadFile(this.dataList[index].datum_id,{
          datum_id:this.dataList[index].datum_id,
          update_state:"confirm"
        }).then(res=>{
          this.$alert(res.data.message,"提示")
        })
      },
      selectAll(){
        this.$refs.dataListTable.toggleAllSelection();
      },
      handleSelectionChange(val){
        console.log(val)
        this.multipleSelection = val;
      },
      //删除多个文件
      deleteBtn(){
        if( this.multipleSelection.length == 0){
          this.$alert('请选择要删除的资料',"提示")
        }else {
          var temp_datum_id ='';
          this.multipleSelection.forEach(el=>{
            temp_datum_id += el.datum_id+","
          })
          this.deleteItem(temp_datum_id).then(res=>{
            this.$alert(res.data.message,"提示")
            if(res.data.code==0){
              this.getTableDataByCondition(this.company_id,this.first_cate,this.second_cate,this.third_cate,this.element_id,this.process_id,this.limit,this.page);
            }
          })
        }
      },
      addData(){
        this.title = "添加资料";
        this.addDataIng = true;
      },
      nodeClick(data,checked,node){
        // console.log(data)
        // console.log(checked)
        // console.log(node)
        this.addDataForm.dacate_id =data.dacate_id ;
        this.$refs.classificationListTree.setCheckedKeys([data.dacate_id]);

        // this.$refs.tree.setCheckedNodes([data]);
      },
      handleClick(data,checked,node){
        // console.log(checked)
        // console.log(data)
        // console.log(node)
        if(checked == true){
          this.$refs.classificationListTree.setCheckedKeys([data.dacate_id]);
        }else {
          this.$refs.classificationListTree.setCheckedKeys([]);
        }
      },
      //dialog中 内控要素改变
      modifyElement(){
        console.log(this.addDataForm.element_id)
        this.getCurrentElementProgress(this.addDataForm.element_id).then(res=>{
          this.addDataForm.process_id = [];
          if(res.data.code==0 && res.data.data.length>0){
            this.currentElementProgressDialog = res.data.data;
            this.addDataForm.process_id.push(res.data.data[0].process_id)
          }
        })
      },
      beforeUploadExamine(file){

        //上传文件限制大小2M
        const isLt2M = file.size / 1024 / 1024 < 5
        if(!isLt2M){
          this.$message({
            message: '上传文件大小不能超过5MB!',
            type: 'warning'
          });
        }
      },
      editData(){
        this.$router.push({
          path:'/controlBuild/classificationList'
        })
      },
      //表格内控要素的筛选
      handleElementList(command){
        this.element_id = command == "all" ?"": command;
        console.log(this.element_id)
        this.getCurrentElementProgress(this.element_id).then(res=>{
          console.log(res);
          if(res.data.code == 0 && res.data.data.length>0){
            this.currentElementProgress = [...res.data.data,{
              common_id: "",
              current_time: "",
              element_id: "",
              is_hascontrolpoint: "",
              is_newest: "",
              numrow: "",
              process_id: "all",
              process_level: "1",
              process_name: "所有",
              process_num: "",
              process_pid: "",
              user_id: "",
            }]
          }

        })
        this.getTableDataByCondition(this.company_id,this.first_cate,this.second_cate,this.third_cate,this.element_id,this.process_id,this.limit,this.page);

      },
      //表格内评价流程的筛选
      handleProgressList(command){
        this.process_id = command == "all" ?"": command;
        this.getTableDataByCondition(this.company_id,this.first_cate,this.second_cate,this.third_cate,this.element_id,this.process_id,this.limit,this.page);
      },
      handleCurrentChange(val) {
        console.log(val);
        this.page = val;
        this.getTableDataByCondition(this.company_id,this.first_cate,this.second_cate,this.third_cate,this.element_id,this.process_id,this.limit,this.page);

      },
      //公司列表选择
      handleCompanyList(command){
          console.log(command)
        this.company_id = command.company_id == "all" ? "" : command.company_id;
        this.companyType =command.company_name
        console.log(this.company_id)

        this.getTableDataByCondition(this.company_id,this.first_cate,this.second_cate,this.third_cate,this.element_id,this.process_id,this.limit,this.page);
      },
      //资料分类 选择
      handleClassificationList(command){
          console.log(command)
        this.first_cate = command.dacate_id == "all" ? "" :command.dacate_id;
          this.classification =command.dacate_name;
        this.getClassificationByCon2List(command).then(res=>{
          console.log(res)
          if(res.data.code==0 && res.data.data.length>0){
            this.classificationByCon2List = [...res.data.data,{
              "dacate_id": "all",
              "dacate_num": "",
              "dacate_name": "所有",
              "dacate_desc": "所有",
              "dacate_pid": "",
              "dacate_level": "",
              "dacate_state": "",
              "current_time": "",
              "numrow": ""
            }] ;
          }
        })

        this.getTableDataByCondition(this.company_id,this.first_cate,this.second_cate,this.third_cate,this.element_id,this.process_id,this.limit,this.page);

      },
      //二级分类选择
      handleClassificationByCon2(command){

        this.second_cate = command == "all" ? "":command

        this.getClassificationByCon3List(command).then(res=>{
          console.log(res)

          if(res.data.code==0 &&  res.data.data.length>0){
            this.classificationByCon3List = [...res.data.data,{
              "dacate_id": "all",
              "dacate_num": "",
              "dacate_name": "所有",
              "dacate_desc": "",
              "dacate_pid": "",
              "dacate_level": "",
              "dacate_state": "",
              "current_time": "",
              "numrow": ""
            }];
          }
        })


      },
      handleClassificationByCon3(command){
        this.third_cate = command;
        this.getTableDataByCondition(this.company_id,this.first_cate,this.second_cate,this.third_cate,this.element_id,this.process_id,this.limit,this.page);
      },
      uploadSuccess(response, file, fileList) {
        console.log(response);
        if (response.code == 0) {
          this.addDataForm.datum_name = response.data.datum_name;
          this.addDataForm.file_path = response.data.file_path;

          this.$alert(response.message, "提示");

        }
        console.log("上传文件", response);

      },
      //添加资料的提交
      submitData(addDataForm){
        this.$refs[addDataForm].validate((valid) => {
          if (valid) {
            if(this.isEditOrModify==0){
              //添加
              this.uploadFile(this.addDataForm).then(res=>{
                this.$alert(res.data.message,"提示")
                if(res.data.code ==0){
                  this.$refs.fileloader.clearFiles()
                  this.getTableDataByCondition(this.company_id,this.first_cate,this.second_cate,this.third_cate,this.element_id,this.process_id,this.limit,this.page);
                }
              })

            }else if(this.isEditOrModify==1){
              //编辑
//              console.log(this.currentDatumId)
              console.log(this.addDataForm);
              this.upDateUploadFile(this.currentDatumId,this.addDataForm).then(res=>{
                this.$alert(res.data.message,"提示")
                if(res.data.code ==0){
                  this.$refs.fileloader.clearFiles()
                  this.getTableDataByCondition(this.company_id,this.first_cate,this.second_cate,this.third_cate,this.element_id,this.process_id,this.limit,this.page);
                }
              }).then(res=>{

              })
            }

          } else {
            this.$alert("提交数据有问题","提示")
            return false;
          }
        });
        this.addDataIng = false
      },
      //关闭弹窗之后
      closeAddData(){
        console.log("xxx")
        this.addDataForm ={
          dacate_id:'',
          element_id:'',
          process_id:[],
          datum_name:'',
          file_path:''
        };
        console.log(this.addDataForm)
      },
      getTableDataByCondition(company_id,first_cate,second_cate,third_cate,element_id,process_id,limit,page){
        if(company_id=='all'){company_id=''}
        // /api/v1/build/datum?company_id=1&first_cate=2&second_cate=4&third_cate=6&element_id=1&process_id=248
        this.axios.get("/api/v1/build/datum?company_id="+company_id+"&first_cate="+first_cate+"&second_cate="+second_cate+"&third_cate="+third_cate+"&element_id="+element_id+"&process_id="+process_id+"&limit="+limit+"&page="+page).then(res=>{
          console.log(res)
          if(res.data.code==0){
            this.dataList = res.data.data;
            this.limit = res.data.pagination.limit;
            this.pages = res.data.pagination.pages;
          }else {
            this.$alert(res.data.message, "提示")
          }

        });
      },
      //获取公司列表
      getCompanyList(){
        this.axios.get('/api/v1/system/comsection').then(res => {
          var all = {
            company_id: "all",
            company_level: "1",
            company_name: "所有",
            company_num: "",
            company_pid: "",
            company_state: "",
            current_time: "",
            evaluate_section: "",
            numrow:"",
            son_company:[]
          }
          if (res.data.code == 0) {
            this.companyList = [ ...res.data.data, all];
          }
          console.log(res.data.data)
          console.log(this.companyList)

        })
      },
      //资料列表
      getClassificationList() {
        //这里只是显示的 分类
        this.axios.get('/api/v1/build/datumquery?is_show=close').then(res => {
          console.log(res.data.data)
          var all = {
            dacate_id: "all",
            dacate_num: "",
            dacate_name: "所有",
            dacate_desc: "所有",
            dacate_pid: "",
            dacate_level: "",
            dacate_state: "",
            current_time: "",
            numrow: "",
            son_dacate: []
          }
          if (res.data.code == 0 && res.data.data.length>0 ) {
            this.classificationList = [...res.data.data,all];
            this.classificationListDialog = res.data.data;
            this.addDataForm.dacate_id = res.data.data[0].dacate_id;
          }
          console.log(this.classificationList)

        })
      },
      //资料分类  全部  包括隐藏的
      getAllClassificationList() {
        //这里全部  包括隐藏的
        this.axios.get('/api/v1/build/datumquery?is_show=close').then(res => {
          console.log(res.data.data)
          if (res.data.code == 0 && res.data.data.length>0 ) {
            this.classificationListDialog = res.data.data;
            this.addDataForm.dacate_id = res.data.data[0].dacate_id;
          }
        })
      },
      //获取一级分类下的二级分类
      getClassificationByCon2List(id){
        // /api/v1/build/datumcategoryquery?first_cate=1
        return this.axios.get('/api/v1/build/datumcategoryquery?first_cate='+ id)
      },
      //获取二级分类下的三级分类
      getClassificationByCon3List(id){
        // /api/v1/build/datumcategoryquery?first_cate=1
        return this.axios.get('/api/v1/build/datumcategoryquery?second_cate='+ id)
      },

      //控制元素列表
      getElementList() {
        return this.axios.get('/api/v1/flow/element')
      },
      //内控元素下的一级流程
      getCurrentElementProgress(element_id){
        // /api/v1/build/datumquery/:element_id
        return this.axios.get('/api/v1/build/datumquery/'+ element_id)
      },
      uploadFile(data){
        return this.axios.post('/api/v1/build/datum',data)
      },
      upDateUploadFile(datum_id,data){
        return this.axios.put('/api/v1/build/datum/'+datum_id,data)
      },
      //删除 一行或者多行
      deleteItem(datum_id){
        return this.axios.delete('/api/v1/build/datum/'+datum_id,{
          datum_id:datum_id
        })
      },
      getDetails(datum_id){
        return this.axios.get('/api/v1/build/datum/'+datum_id)
      }

    }
  })
</script>
<style scoped="">
  .userMaIndex {
    width: 100%;
    height: 100%;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    padding: 10px;
  }

  .userMaIndex .navList{
    padding-bottom:12px;
    margin-bottom:12px;
  }

  .userMaIndex .el-table >>> th.is-leaf {
    background: #d3e9bb;
    height: 58px;
  }

  .arrow{
    display: inline-block;
    width: 17px;
    height:15px;
    margin-left:4px;
    border-radius:4px;
    position: relative;
  }
  .arrow::after{
    content:'';
    display: block;
    width:100%;
    height:100%;
    position: absolute;
    left:0;
    top:2px;
    background: #afd682 url("../../static/images/icon-down.png") no-repeat center;
  }

  .userMaIndex .e-table-footer {
    background: #d3e9bb;
    height: 50px;
    line-height: 50px;
    border-bottom: 1px solid #aac983;
    border-right: 1px solid #aac983;
  }

  .userMaIndex .e-table-footer .e-selectAll {
    width: 55px;
    text-align: center;
    border-left: 1px solid #aac983;
    border-right: 1px solid #aac983;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    display: inline-block;
  }

  .userMaIndex .e-table-footer .e-selectText {
    display: inline-block;
    margin-left: 20px;
    color: #5d9120;
  }

  .userMaIndex .e-selectText .e-del {
    font-size: 16px;
    color: #fff;
    padding: 6px 20px;
    background: #f56c6c;
    border-radius: 2px;
    -webkit-border-radius: 2px;
    margin-left: 30px;
    cursor: pointer;
  }
  .file-uploader .upload-button{
    background:#769dd6;
    color:#fff;
    border-color:#769dd6;
    cursor: pointer;
    display: inline-block;
    width: 90px;
    height: 32px;
    line-height: 32px;
    border-radius: 5px;
  }
</style>
